package toman.jpa;

import toman.Prop;
import toman.orm.TO;

import java.util.List;

@TO(
    id = "a.name=:albumName",
    // This would work also, however, it wouldn't perform so well because the photos are loaded lazily in
    // a separate query (when calling the getPhotos getter) and not during the main query.
    //read = "select a from Album a",
    read = "select a from Album a inner join fetch a.photos",
    write = "update Album a set a.name=:albumName")
public class BasicAlbumWithPhotosTO {

    @Prop("name")
    private String albumName;

    @Prop("photos")
    private List<Photo> photos;

    public String getAlbumName() {
        return albumName;
    }

    public void setAlbumName(String albumName) {
        this.albumName = albumName;
    }

    public List<Photo> getPhotos() {
        return photos;
    }

    public void setPhotos(List<Photo> photos) {
        this.photos = photos;
    }
}
